<template>
	<view class="order-list">
		<view class="tabs-wrap">
			<view :style="{'border-bottom': '2rpx solid #efefef'}">
				<u-tabs :ref="tabDat.ref" :list="tabDat.tabList" :current="tabDat.currTab" :is-scroll="false"
					activeColor="#00c3ce" @change="tabChange"></u-tabs>
				<template v-if='tabDat.currTab == 0'>
					<u-tabs :is-scroll="false" :ref="tabDat.ref2" :list="tabDat.tabList2" :current="tabDat.currTab2"
						activeColor="#00c3ce" @change="tabChange2"></u-tabs>
				</template>
				<template v-if='tabDat.currTab == 1'>
					<u-tabs :is-scroll="false" :ref="tabDat.ref4" :list="tabDat.tabList4" :current="tabDat.currTab4"
						activeColor="#00c3ce" @change="tabChange4"></u-tabs>

					<template v-if='tabDat.currTab4 == 0'>
						<u-tabs :is-scroll="false" :ref="tabDat.ref3" :list="tabDat.tabList3" :current="tabDat.currTab3"
							activeColor="#00c3ce" @change="tabChange3"></u-tabs>
					</template>
					<template v-if='tabDat.currTab4 == 1'>
						<u-tabs :is-scroll="false" :ref="tabDat.ref5" :list="tabDat.tabList5" :current="tabDat.currTab5"
							activeColor="#00c3ce" @change="tabChange5"></u-tabs>
					</template>
				</template>
				<template v-if='tabDat.currTab == 2'>

				</template>
			</view>
			<view class="list-container">
				<template v-if='tabDat.currTab == 0'>
					<WeiPai v-if='tabDat.currTab2 == 0'></WeiPai>
					<YiPai v-if='tabDat.currTab2 == 1'></YiPai>
					<WanTuan v-if='tabDat.currTab2 == 2'></WanTuan>
				</template>
				<template v-if='tabDat.currTab == 1 && tabDat.currTab4 == 0'>
					<WeiJei v-if='tabDat.currTab3 == 0'></WeiJei>
					<YiJei v-if='tabDat.currTab3 == 1'></YiJei>
					<YiPaiChe v-if='tabDat.currTab3 == 2'></YiPaiChe>
				</template>
				<template v-if='tabDat.currTab == 1 && tabDat.currTab4 == 1'>
					<weifabu v-if='tabDat.currTab5 == 0'></weifabu>
					<Yifabu v-if='tabDat.currTab5 == 1'></Yifabu>
				</template>
				<template v-if='tabDat.currTab == 2'>

					<AddOrder></AddOrder>
				</template>

			</view>


		</view>
		<u-tabbar :list="tabbar"></u-tabbar>
	</view>
</template>

<script>
	import WeiPai from './order2-baoche/order2-baoche_weipai.vue';
	import YiPai from './order2-baoche/order2-baoche-yipaiche.vue';
	import WanTuan from './order2-baoche/order2-baoche-yiwantuan.vue';
	import WeiJei from './order2-pinche/order2-baoche_weijie.vue';
	import weifabu from './order2-pinche/order2-baoche_weifabu.vue';
	import Yifabu from './order2-pinche/order2-baoche_yifabu.vue';
	import YiJei from './order2-pinche/order2-baoche-yijie.vue';
	import YiPaiChe from './order2-pinche/order2-baoche-yipaiche.vue';
	import AddOrder from './add-order/add-order.vue';
	export default {
		components: {
			WeiPai,
			YiPai,
			WanTuan,
			WeiJei,
			YiJei,
			YiPaiChe,
			AddOrder,
			weifabu,
			Yifabu,
		},
		onLoad(e) {


		},
		mounted() {
		
			let that = this
			setTimeout(() => {
				that.dataaa = 1
			}, 3000);
			let tabs_page = uni.getStorageSync('tabs_page');
		
		
			if (tabs_page.tabs1 == 1) {
				uni.removeStorageSync('tabs_page');
				that.tabDat.currTab = 0
				if (tabs_page.tabs2 == 1) {
					that.tabDat.currTab2 = 0
				} else if (tabs_page.tabs2 == 2) {
					that.tabDat.currTab2 = 1
				} else if (tabs_page.tabs2 == 3) {
					that.tabDat.currTab2 = 2
				}
			} else if (tabs_page.tabs1 == 2) {
				uni.removeStorageSync('tabs_page');
				that.tabDat.currTab = 1
				that.tabDat.currTab4 = 0
				if (tabs_page.tabs2 == 1) {
					that.tabDat.currTab3 = 0
				} else if (tabs_page.tabs2 == 2) {
					that.tabDat.currTab3 = 1
				} else if (tabs_page.tabs2 == 3) {
					that.tabDat.currTab3 = 2
				}
		
			} else if (tabs_page.tabs1 == 3) {
				that.tabDat.currTab = 2
		
			} else if (tabs_page.tabs1 == 4) {
				that.tabDat.currTab = 1
				that.tabDat.currTab4 = 1
				that.tabDat.currTab5 = 0
			}
			uni.removeStorageSync('tabs_page');
			that.qiangdan_list()
			// 禁用右上角的分享，但可以使用手动触发分享
			// 	uni.hideShareMenu();
		
			// 	that.getNoOrderList(1);
			// 	that.getAlOrderList(1);
		
			// // 其他页面跳转回当前页刷新列表
			// uni.$on('refOrderList', () => {
			// 	that.$nextTick(function() {
			// 		that.getNoOrderList(1);
			// 		that.getAlOrderList(1);
			// 	});
			// });
		
		
		},
		onUnload() {
			// // 移除监听
			// uni.$off('refOrderList', this.refOrderList);
		},
		data() {
			return {
				tabbar: '',
				count: 0,
				// tab数据对象
				tabDat: {
					ref: 'orderListTabs2',
					ref2: 'orderListTabs3',
					ref3: 'orderListTabs4',
					ref4: 'orderListTabs5',
					ref5: 'orderListTabs6',
					tabList: [{
							name: '包车'
						},
						{
							name: '拼车'
						},
						{
							name: '添加订单'
						},
					],
					tabList2: [{
							name: '未派车'
						},
						{
							name: '已派车'
						},
						{
							name: '已完团'
						},
					],
					tabList3: [{
							name: '未接到'
						},
						{
							name: '已接到'
						},
						{
							name: '已派车'
						},
					],
					tabList4: [{
							name: '拼车接天府'
						},
						{
							name: '拼车送天府'
						},
					],
					tabList5: [{
							name: '未发布'
						},
						{
							name: '已发布'
						},
					],


					// 当前激活的tab索引
					currTab: 0,
					currTab2: 0,
					currTab3: 0,
					currTab4: 0,
					currTab5: 0,
				},
				dataaa: 0,
			}
		},
		methods: {
			// tabs通知swiper切换
			tabChange(index) {
				console.log(index)
				this.tabDat.currTab = index;
			},
			tabChange2(index) {
				console.log(index)
				this.tabDat.currTab2 = index;
			},
			tabChange3(index) {
				console.log(index)
				this.tabDat.currTab3 = index;
			},
			tabChange4(index) {
				console.log(index)
				this.tabDat.currTab4 = index;
			},
			tabChange5(index) {
				console.log(index)
				this.tabDat.currTab5 = index;
			},
			qiangdan_list() {
					let timer =null
					clearTimeout(timer)
					let that = this
					let currentDate = new Date();
			
					// 提取年月日部分
					let year = currentDate.getFullYear();
					let month = String(currentDate.getMonth() + 1).padStart(2, '0');
					let day = String(currentDate.getDate()).padStart(2, '0');
			
					let todayString = `${year}-${month}-${day}`;
					let data = todayString + ' ' + '00:00:00'
			
					let nextWeekDate = new Date(currentDate.getTime() + 7 * 24 * 60 * 60 * 1000);
					// 提取年月日部分
					let year2 = nextWeekDate.getFullYear();
					let month2 = String(nextWeekDate.getMonth() + 1).padStart(2, '0');
					let day2 = String(nextWeekDate.getDate()).padStart(2, '0');
			
					let nextWeekDateString2 = `${year2}-${month2}-${day2}`;
					let data2 = nextWeekDateString2 + ' ' + '23:59:59'
			
					that.$u.api.getOrderReadyList({
						page: {
							pageNum: 1,
							pageSize: 999,
						},
						status: '',
						routeSimpleName: '',
						timeType: '0',
						stime: data,
						etime: data2,
					}).then(res => {
						if (res.code == 1) {
							if (res.data.total == 0) {
								that.tabbar = [{
										iconPath: "/static/tabbar/order.png",
										selectedIconPath: "/static/tabbar/order-sel.png",
										text: '订单',
										isDot: false,
										pagePath: "/pages/tabbar/order-list/order-list"
									},
									{
										iconPath: "/static/tabbar/notice.png",
										selectedIconPath: "/static/tabbar/bz-sel.png",
										text: '抢单',
										isDot: false,
										pagePath: "/pages/tabbar/my-notice/my-notice"
									},
									{
										iconPath: "/static/tabbar/bz.png",
										selectedIconPath: "/static/tabbar/notice-sel.png",
										text: '报账',
										isDot: false,
										pagePath: "/pages/tabbar/order-bz-list/order-bz-list"
									}, {
										iconPath: "/static/tabbar/user.png",
										selectedIconPath: "/static/tabbar/user-sel.png",
										text: '我的',
										isDot: false,
										pagePath: "/pages/tabbar/my/my"
									}
								]
							} else {
								that.tabbar = [{
										iconPath: "/static/tabbar/order.png",
										selectedIconPath: "/static/tabbar/order-sel.png",
										text: '订单',
										isDot: false,
										pagePath: "/pages/tabbar/order-list/order-list"
									},
									{
										iconPath: "/static/tabbar/notice.png",
										selectedIconPath: "/static/tabbar/bz-sel.png",
										text: '抢单',
										isDot: true,
										pagePath: "/pages/tabbar/my-notice/my-notice"
									},
									{
										iconPath: "/static/tabbar/bz.png",
										selectedIconPath: "/static/tabbar/notice-sel.png",
										text: '报账',
										isDot: false,
										pagePath: "/pages/tabbar/order-bz-list/order-bz-list"
									}, {
										iconPath: "/static/tabbar/user.png",
										selectedIconPath: "/static/tabbar/user-sel.png",
										text: '我的',
										isDot: false,
										pagePath: "/pages/tabbar/my/my"
									}
								]
							}
			
			
						} else {
							that.tabbar = [{
									iconPath: "/static/tabbar/order.png",
									selectedIconPath: "/static/tabbar/order-sel.png",
									text: '订单',
									isDot: false,
									pagePath: "/pages/tabbar/order-list/order-list"
								},
								{
									iconPath: "/static/tabbar/notice.png",
									selectedIconPath: "/static/tabbar/bz-sel.png",
									text: '抢单',
									isDot: false,
									pagePath: "/pages/tabbar/my-notice/my-notice"
								},
								{
									iconPath: "/static/tabbar/bz.png",
									selectedIconPath: "/static/tabbar/notice-sel.png",
									text: '报账',
									isDot: false,
									pagePath: "/pages/tabbar/order-bz-list/order-bz-list"
								}, {
									iconPath: "/static/tabbar/user.png",
									selectedIconPath: "/static/tabbar/user-sel.png",
									text: '我的',
									isDot: false,
									pagePath: "/pages/tabbar/my/my"
								}
							]
						}
						timer = setTimeout(() => {
						
							that.qiangdan_list()
						}, 300000);
					});
			
			
				}
			

		},
		
	}
</script>

<style lang="scss" scoped>
	.order-list {
		background: #efefef;
		overflow-y: hidden;

		// 弹框样式
		.md-content {
			padding: 10rpx;

			.my-box-shadow {
				border-radius: 12rpx;
				background: #fff;
				padding: 0 10rpx;
				box-shadow: 0 2rpx 3rpx rgba(0, 0, 0, 0.1);
			}
		}

		.tabs-wrap {
			display: flex;
			flex-direction: column;
			height: calc(100vh - var(--window-top));
			width: 100%;
			overflow-y: hidden;

			.tab-swiper-box {
				flex: 1;

				.tab-swiper-item {
					height: 100%;

					.page-box {
						padding-bottom: 80rpx;
					}
				}
			}
		}

		.no-data {
			margin-top: 50px;
		}

		.order {
			width: 710rpx;
			background-color: #ffffff;
			margin: 20rpx auto;
			border-radius: 10rpx;
			box-sizing: border-box;
			padding: 20rpx;
			font-size: 28rpx;

			.top {
				display: flex;
				justify-content: space-between;

				.left {
					display: flex;
					align-items: center;

					.store {
						margin: 0 10rpx;
						font-size: 32rpx;
						font-weight: bold;
					}
				}

				.right {
					color: $u-type-warning-dark;
				}
			}

			.item {
				display: block;
				margin: 0rpx 0 0;

				.content {
					.title {
						font-size: 28rpx;
						line-height: 50rpx;
					}

					.type {
						margin: 10rpx 0;
						font-size: 24rpx;
						color: $u-tips-color;

						.service-type {
							float: right;
						}
					}

					.delivery-time {
						color: #e5d001;
						font-size: 24rpx;
					}
				}

				.bottom {
					display: flex;
					margin-top: 20rpx;
					justify-content: flex-end;
					align-items: center;

					.btn {
						line-height: 52rpx;
						padding: 0rpx 16rpx;
						border-radius: 26rpx;
						border: 2rpx solid #ff9900;
						font-size: 26rpx;
						text-align: center;
						color: #ff9900;
						;
						margin-right: 10rpx;
					}

					.more {
						align-self: center;
						flex: 1;
						margin-right: 10rpx;
					}

					.evaluate {
						color: $u-type-warning-dark;
						border-color: $u-type-warning-dark;
					}
				}

			}

		}

	}
</style>